fix: resolve failing tests and type errors across api and shared packages - #104
Open
stooit wants to merge 1 commit into
Open
fix: resolve failing tests and type errors across api and shared packages#104stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
…ages - implement paginate() in shared with correct edge-case handling - fix case-sensitive HTTP method comparison in auth middleware (POST) - add missing badRequest import in users route - rename User.userName -> username to match tests and routes - add bun-types to tsconfig so tsc resolves bun:test and process
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes all failing tests and type errors in the repository.
bun testnow reports 22 pass / 0 fail andbunx tsc --noEmitis clean.Changes
packages/shared/src/utils/pagination.ts— implemented the previously-stubbedpaginate<T>(). Handles all edge cases: empty array (totalPages: 0, noNaN), out-of-range page (empty slice), partial last page, and correcttotal/totalPages/page/pageSizefields.packages/api/src/middleware/auth.ts— fixed a case-sensitivity bug in the HTTP-method comparison soPOST /usersis correctly matched as a public route (no token required).packages/api/src/routes/users.ts— added the missingbadRequestresponse-helper import that caused a runtime failure / type error, fixing the "returns 400 for missing fields" test.packages/shared/src/types.ts— renamedUser.userName→usernameto match what the routes and tests use. Updated all non-test usages.tsconfig.json— added"types": ["bun-types"]sotscresolvesbun:testandprocessfor the type-check.Verification
bun test→ 22 pass, 0 fail (4 files, 37 assertions)bunx tsc --noEmit→ no errorsConstraints honoured
Assumptions
usernamefield (notuserName) is canonical, since tests and route handlers use it and the type comment flagged the mismatch as a bug.bun-typeswas already available in the workspace; the tsconfig change only brings it into scope for type-checking.